import { defineStore } from 'pinia';
//@ts-ignore
export const useSharedFilesStore = defineStore('sharedFiles', {
  state: (): {
    sharedFiles: any[];
  } => ({
    sharedFiles: [],
  }),
  actions: {
    setSharedFiles(files: any[]) {
      this.sharedFiles = files;
    },
    addSharedFile(file: any) {
      this.sharedFiles.push(file);
    },
    removeSharedFile(fileId: any) {
      this.sharedFiles = this.sharedFiles.filter(file => file.id !== fileId);
    },
  },
  persist: {
    key: 'sharedFilesStore',
    storage: sessionStorage,
    paths: ['sharedFiles'],
  },
});